/**
 * @addtogroup os_task
 * os_task
 * @{
 */
/**
 * @file        os_task.h
 * @brief       XXXX
 * @note        XXXX
 * @author      靳普诏(puzhao.jin@hopechart.com)
 * @date        2025/09/15
 * @version     1.0

 * @par         修改日志
 * <table>
 * <tr><th>Date         <th>Version     <th>Author      <th> Description
 * <tr><td>2025/09/15   <td>1.0         <td>靳普诏       <td> 创建初始版本
 * @copyright 杭州鸿泉物联网技术股份有限公司
 */

#ifndef _OS_TASK_H_
#define _OS_TASK_H_

#include "az_clib/BaseTypes.h"





#ifdef __cplusplus
extern "C"
{
#endif

typedef UInt8 TOsTaskPriority;
enum TOsTaskPriorityTag
{
    kOsTaskPriorityLevel0 = 0,
    kOsTaskPriorityLevel1 = 1,
    kOsTaskPriorityLevel2 = 2,
    kOsTaskPriorityLevel3 = 3,
    kOsTaskPriorityLevel4 = 4,
    kOsTaskPriorityLevel5 = 5,

    kOsTaskPriorityLow = 1,
    kOsTaskPriorityNormal = 3,
    kOsTaskPriorityHigh = 5,
};

typedef UInt8 TOsTaskState;
enum TOsTaskStateTag
{
    kOsTaskStateDestroy = 0,
    kOsTaskStateCreate = 1,
    kOsTaskStateIdle = 2,
    kOsTaskStateStarting = 3,
    kOsTaskStateRunning = 4,
    kOsTaskStateStopping = 5,
};



typedef struct TOsTaskTag TOsTask;

typedef void (*TOsTaskOnExecMethod)(TOsTask *self);

typedef struct TOsTaskParamTag TOsTaskParam;
struct TOsTaskParamTag
{
    TOsTaskPriority     priority;

    UInt32              task_id;
    char                *task_name;
    UInt32              stack_size;
    UInt8               *stack_addr;
    
    TOsTaskOnExecMethod  on_start_method;
    TOsTaskOnExecMethod  on_run_method;
    TOsTaskOnExecMethod  on_stop_method;
};

struct TOsTaskTag
{
    void *task_handle_;

    TOsTaskParam        params;

    Bool                req_destroy_;  //  请求销毁
    Bool                req_stop_;   //  请求停止
    Bool                req_start_;  //  请求开始
    TOsTaskState        state_;  //  请求开始
};


Int32 TOsTaskCreate(TOsTask *self, const TOsTaskParam *params);
void  TOsTaskDestroy(TOsTask *self);

Int32 TOsTaskStart(TOsTask *self);
Int32 TOsTaskStop(TOsTask *self);

Bool TOsTaskIsRunning(TOsTask *self);

Bool TOsTaskReqStop(TOsTask *self);



#ifdef __cplusplus
}  ///< extern "C"
#endif

#endif  ///< _OS_TASK_H_

/**
 * @}  Generated on "2025-09-15 22:37:51" by the tool "gen_hq_file.py >> V20231119" 
 */

